package learning.controller;
import learning.domain.ChatMessage;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

@Controller
public class ChatController {

    // 接收客户端发送的消息，并将消息发送给所有订阅了"/topic/chat"的客户端
    @MessageMapping("/chat")
    @SendTo("/topic/chat")
    public ChatMessage sendMessage(ChatMessage chatMessage) {
        return chatMessage;
    }
}
